<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>源码安装Apache+PHP+Mysql实战 | Aurthur Article</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="安装的过程整体要分为三大过程：

安装 apache 和 mysql
安装 PHP
安装 memcached  php-memcache

安装 apache 和 mysql 第一步  下载 apache、mysql 并且为二者建立对应的安装目录
123456mkdir –p /opt/softcd /opt/softwget http://download.chyangwa.com/linux/">
<meta property="og:type" content="article">
<meta property="og:title" content="源码安装Apache+PHP+Mysql实战">
<meta property="og:url" content="http://aurthur.gitos.cn/Aurthur-2015/SourceCode-Install-LAMP.html">
<meta property="og:site_name" content="Aurthur Article">
<meta property="og:description" content="安装的过程整体要分为三大过程：

安装 apache 和 mysql
安装 PHP
安装 memcached  php-memcache

安装 apache 和 mysql 第一步  下载 apache、mysql 并且为二者建立对应的安装目录
123456mkdir –p /opt/softcd /opt/softwget http://download.chyangwa.com/linux/">
<meta property="og:updated_time" content="2017-01-07T12:46:31.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="源码安装Apache+PHP+Mysql实战">
<meta name="twitter:description" content="安装的过程整体要分为三大过程：

安装 apache 和 mysql
安装 PHP
安装 memcached  php-memcache

安装 apache 和 mysql 第一步  下载 apache、mysql 并且为二者建立对应的安装目录
123456mkdir –p /opt/softcd /opt/softwget http://download.chyangwa.com/linux/">
  
  
    <link rel="icon" href="/uploads/blog.ico">
  
  <link rel="stylesheet" href="/css/style.css">
</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
	<header id="header" class="inner">
		<a href="/" class="profilepic">
			
			<img lazy-src="/uploads/blog.png" class="js-avatar">
			
		</a>

		<hgroup>
		  <h1 class="header-author"><a href="/">Aurthur</a></h1>
		</hgroup>

		
		<p class="header-subtitle">Aurthur Blog</p>
		

		
			<div class="switch-btn">
				<div class="icon">
					<div class="icon-ctn">
						<div class="icon-wrap icon-house" data-idx="0">
							<div class="birdhouse"></div>
							<div class="birdhouse_holes"></div>
						</div>
						<div class="icon-wrap icon-ribbon hide" data-idx="1">
							<div class="ribbon"></div>
						</div>
						
						
						<div class="icon-wrap icon-me hide" data-idx="3">
							<div class="user"></div>
							<div class="shoulder"></div>
						</div>
						
					</div>
					
				</div>
				<div class="tips-box hide">
					<div class="tips-arrow"></div>
					<ul class="tips-inner">
						<li>菜单</li>
						<li>标签</li>
						
						
						<li>关于我</li>
						
					</ul>
				</div>
			</div>
		

		<div class="switch-area">
			<div class="switch-wrap">
				<section class="switch-part switch-part1">
					<nav class="header-menu">
						<ul>
						
							<li><a href="/">主页</a></li>
				        
							<li><a href="/archives">所有文章</a></li>
				        
						</ul>
					</nav>
					<nav class="header-nav">
						<div class="social">
							
								<a class="github" target="_blank" href="https://github.com/aurthurxlc" title="github">github</a>
					        
								<a class="zhihu" target="_blank" href="https://www.zhihu.com/people/aurthur" title="zhihu">zhihu</a>
					        
								<a class="mail" target="_blank" href="/aurthurxlc@gmail.com" title="mail">mail</a>
					        
								<a class="google" target="_blank" href="https://plus.google.com/u/0/110645540964195673210" title="google">google</a>
					        
						</div>
					</nav>
				</section>
				
				
				<section class="switch-part switch-part2">
					<div class="widget tagcloud" id="js-tagcloud">
						<a href="/tags/ADB/" style="font-size: 10px;">ADB</a> <a href="/tags/API/" style="font-size: 10px;">API</a> <a href="/tags/Android/" style="font-size: 10px;">Android</a> <a href="/tags/Apache/" style="font-size: 12.5px;">Apache</a> <a href="/tags/CentOS/" style="font-size: 15px;">CentOS</a> <a href="/tags/Centos/" style="font-size: 12.5px;">Centos</a> <a href="/tags/Chkconfig/" style="font-size: 10px;">Chkconfig</a> <a href="/tags/Electron/" style="font-size: 10px;">Electron</a> <a href="/tags/FTP/" style="font-size: 10px;">FTP</a> <a href="/tags/FastCGI/" style="font-size: 10px;">FastCGI</a> <a href="/tags/Iterm/" style="font-size: 10px;">Iterm</a> <a href="/tags/Java/" style="font-size: 15px;">Java</a> <a href="/tags/Kernel/" style="font-size: 10px;">Kernel</a> <a href="/tags/Linux/" style="font-size: 17.5px;">Linux</a> <a href="/tags/Mac/" style="font-size: 12.5px;">Mac</a> <a href="/tags/Mirror/" style="font-size: 10px;">Mirror</a> <a href="/tags/Mysql/" style="font-size: 12.5px;">Mysql</a> <a href="/tags/Nginx/" style="font-size: 12.5px;">Nginx</a> <a href="/tags/PHP/" style="font-size: 20px;">PHP</a> <a href="/tags/RESTful/" style="font-size: 10px;">RESTful</a> <a href="/tags/Regular-Expression/" style="font-size: 10px;">Regular Expression</a> <a href="/tags/SSH/" style="font-size: 10px;">SSH</a> <a href="/tags/SSL/" style="font-size: 10px;">SSL</a> <a href="/tags/Sass/" style="font-size: 10px;">Sass</a> <a href="/tags/Server/" style="font-size: 10px;">Server</a> <a href="/tags/Terminal/" style="font-size: 10px;">Terminal</a> <a href="/tags/Ubuntu/" style="font-size: 10px;">Ubuntu</a> <a href="/tags/VPN/" style="font-size: 10px;">VPN</a> <a href="/tags/Vagrant/" style="font-size: 10px;">Vagrant</a> <a href="/tags/Volume/" style="font-size: 12.5px;">Volume</a> <a href="/tags/Web/" style="font-size: 12.5px;">Web</a> <a href="/tags/Windows/" style="font-size: 10px;">Windows</a> <a href="/tags/compile/" style="font-size: 10px;">compile</a> <a href="/tags/dd/" style="font-size: 10px;">dd</a> <a href="/tags/develop-tools/" style="font-size: 10px;">develop tools</a> <a href="/tags/gitlab/" style="font-size: 10px;">gitlab</a> <a href="/tags/go/" style="font-size: 12.5px;">go</a> <a href="/tags/gzip/" style="font-size: 10px;">gzip</a> <a href="/tags/hook/" style="font-size: 10px;">hook</a> <a href="/tags/java/" style="font-size: 10px;">java</a> <a href="/tags/mod-php/" style="font-size: 10px;">mod_php</a> <a href="/tags/ntp/" style="font-size: 10px;">ntp</a> <a href="/tags/supervisor/" style="font-size: 10px;">supervisor</a> <a href="/tags/web/" style="font-size: 10px;">web</a> <a href="/tags/zimg/" style="font-size: 12.5px;">zimg</a>
					</div>
				</section>
				
				
				

				
				
				<section class="switch-part switch-part3">
				
					<div id="js-aboutme">true</div>
				</section>
				
			</div>
		</div>
	</header>				
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
  	<div class="overlay">
  		<div class="slider-trigger"></div>
  		<h1 class="header-author js-mobile-header hide">Aurthur</h1>
  	</div>
	<div class="intrude-less">
		<header id="header" class="inner">
			<div class="profilepic">
				<img lazy-src="/uploads/blog.png" class="js-avatar">
			</div>
			<hgroup>
			  <h1 class="header-author">Aurthur</h1>
			</hgroup>
			
			<p class="header-subtitle">Aurthur Blog</p>
			
			<nav class="header-menu">
				<ul>
				
					<li><a href="/">主页</a></li>
		        
					<li><a href="/archives">所有文章</a></li>
		        
		        <div class="clearfix"></div>
				</ul>
			</nav>
			<nav class="header-nav">
				<div class="social">
					
						<a class="github" target="_blank" href="https://github.com/aurthurxlc" title="github">github</a>
			        
						<a class="zhihu" target="_blank" href="https://www.zhihu.com/people/aurthur" title="zhihu">zhihu</a>
			        
						<a class="mail" target="_blank" href="/aurthurxlc@gmail.com" title="mail">mail</a>
			        
						<a class="google" target="_blank" href="https://plus.google.com/u/0/110645540964195673210" title="google">google</a>
			        
				</div>
			</nav>
		</header>				
	</div>
</nav>
      <div class="body-wrap"><article id="post-SourceCode-Install-LAMP" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/Aurthur-2015/SourceCode-Install-LAMP.html" class="article-date">
  	<time datetime="2017-01-07T12:46:31.000Z" itemprop="datePublished">2017-01-07</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      源码安装Apache+PHP+Mysql实战
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
	<div class="article-tag tagcloud">
		<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Apache/">Apache</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Linux/">Linux</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Mysql/">Mysql</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/PHP/">PHP</a></li></ul>
	</div>

        
	<div class="article-category tagcloud">
	<a class="article-category-link" href="/categories/Technical/">Technical</a>
	</div>


        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>安装的过程整体要分为三大过程：</p>
<ul>
<li>安装 apache 和 mysql</li>
<li>安装 PHP</li>
<li>安装 memcached  php-memcache</li>
</ul>
<h2 id="安装_apache_和_mysql">安装 apache 和 mysql</h2><p><strong> 第一步  下载 apache、mysql 并且为二者建立对应的安装目录</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">mkdir –p /opt/soft</span><br><span class="line"><span class="built_in">cd</span> /opt/soft</span><br><span class="line">wget http://download.chyangwa.com/linux/apache/httpd-2.2.4.tar.gz</span><br><span class="line">wget http://download.chyangwa.com/linux/MySQL/mysql-5.0.19.tar.gz</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/apache</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/mysql</span><br></pre></td></tr></table></figure>
<a id="more"></a>
<p><strong> 第二步 解压以及安装 apache </strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">tar –zxvf httpd-2.2.4.tar.gz</span><br><span class="line">tar –zxvf mysql-5.0.19.tar.gz</span><br><span class="line"><span class="built_in">cd</span> httpd-2.2.4</span><br><span class="line">./configure --prefix=/usr/<span class="built_in">local</span>/apache --enable-so --enable-rewrite --enable-deflate --with-mpm=worker</span><br><span class="line">make &amp;&amp; make install</span><br><span class="line">make clean</span><br><span class="line"><span class="built_in">cd</span></span><br></pre></td></tr></table></figure>
<p>启动服务：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/usr/<span class="built_in">local</span>/apache/bin/apachectl –k start</span><br></pre></td></tr></table></figure></p>
<p>然后在地址栏里面输入：本机IP/index.html 如果可以看到“It works!”</p>
<p>就说明 apache 已经安装成功了</p>
<p><strong> 第三步 解压以及安装 mysql </strong></p>
<p>建立数据库的用户和用户组：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">groupadd mysql</span><br><span class="line">useradd -g mysql mysql</span><br></pre></td></tr></table></figure></p>
<p>编译安装数据库：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"> <span class="built_in">cd</span> mysql-5.0.19</span><br><span class="line"> ./configure --prefix=/usr/<span class="built_in">local</span>/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-assembler --disable-shared --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-staticm --with-embedded-server --with-innodb --with-extra-charsets=gbk,gb2312,big5 --without-debug CFLAGS=-O3 -mcpu=pentium4 CXXFLAGS=-O3 -march=pentium4 -felide-constructors -fno-exceptions -fno-rtti CXX=gcc</span><br><span class="line"> make &amp;&amp; make install</span><br><span class="line"> make clean</span><br><span class="line"> cp -r mysql-5.0.19 /usr/<span class="built_in">local</span>/mysql</span><br><span class="line"> cp support-files/mysql.server /etc/rc.d/init.d/mysql</span><br><span class="line"> cp support-files/my-medium.cnf /etc/my.cnf</span><br><span class="line">```bash</span><br><span class="line">修改mysql目录权限</span><br><span class="line">```bash</span><br><span class="line"> chown -R root /usr/<span class="built_in">local</span>/mysql</span><br><span class="line"> chgrp -R mysql /usr/<span class="built_in">local</span>/mysql</span><br><span class="line"> chown -R mysql /usr/<span class="built_in">local</span>/mysql/data</span><br></pre></td></tr></table></figure></p>
<p>生成mysql系统数据库<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">/usr/<span class="built_in">local</span>/mysql/bin/mysql_install_db --user=mysql&amp;  </span><br><span class="line">/usr/<span class="built_in">local</span>/mysql/bin/mysqld_safe --user=mysql&amp;</span><br></pre></td></tr></table></figure></p>
<p><strong> 如出现 Starting mysqld daemon with databases from /usr/local/mysql/data 代表正常启动mysql服务了.</strong></p>
<p>make install 结束后，新安装的需要执行 bin/mysql_install_db 文件来安装授权表，然后运行 bin/mysqld_safe 启动 mysql 服务</p>
<p>用 mysql 命令看是否能连接到服务器</p>
<p>在 ./configure 的时候通常都会出现 checking for termcap functions library… configure: error: No curses/termcap library found这个错误！安装上 libncurses5-dev (不同的系统可能名字也有所差异)这个包就好了</p>
<h2 id="安装_PHP">安装 PHP</h2><p><strong> 第一步 下载需要的组件(可以根据工作需要定制)</strong><br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/soft</span><br><span class="line">wget http://download.chyangwa.com/linux/freetype/freetype-2.2.1.tar.gz</span><br><span class="line">wget http://download.chyangwa.com/linux/GD/gd-2.0.33.tar.gz</span><br><span class="line">wget http://download.chyangwa.com/linux/zlib/zlib-1.2.3.tar.gz</span><br><span class="line">wget http://download.chyangwa.com/linux/jpegsrc/jpegsrc.v6b.tar.gz</span><br><span class="line">wget ftp://ftp.gnu.org/gnu/gdbm/gdbm-1.8.2.tar.gz</span><br><span class="line">wget http://download.chyangwa.com/linux/gettext/gettext-0.14.5.tar.gz</span><br><span class="line">wget http://download.chyangwa.com/linux/libiconv/libiconv-1.10.tar.gz</span><br><span class="line">wget http://download.chyangwa.com/linux/libxml/libxml-1.8.17.tar.gz</span><br><span class="line">wget http://download.chyangwa.com/linux/PHP/php-5.0.5.tar.gz</span><br><span class="line">wget http://www.libpng.org/pub/png/libpng.html/libpng-1.2.25.tar.gz</span><br></pre></td></tr></table></figure></p>
<p>为以上的安装包建立目录<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">mkdir –p /usr/<span class="built_in">local</span>/libxml</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/freetype</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/gd2</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/zlib</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/jpeg</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/gdbm</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/gettext</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/libiconv</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/libxml</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/php</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/libpng</span><br></pre></td></tr></table></figure></p>
<p><strong> 第二步  安装 PHP 相关连的包</strong></p>
<ol>
<li><p>安装 jpeg6 建立目录：如果选择默认安装,可能很顺利,指定路径后,请先创建以下文件夹</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">mkdir –p /usr/<span class="built_in">local</span>/jpeg6</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/jpeg6/bin</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/jpeg6/lib</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/jpeg6/include</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/jpeg6/man</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/jpeg6/man1</span><br><span class="line">mkdir –p /usr/<span class="built_in">local</span>/jpeg6/man/man1</span><br><span class="line"><span class="built_in">cd</span> /opt/soft/</span><br><span class="line">tar –zvxf jpegsrc.v6b.tar.gz</span><br><span class="line"><span class="built_in">cd</span> jpeg6</span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/jpeg6/ --enable-shared –<span class="built_in">enable</span>-static</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make install-lib</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure>
</li>
<li><p>libpng 包(支持 PNG)</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/soft/</span><br><span class="line">tar –zvxf libpng-(version).tar.gz</span><br><span class="line"><span class="built_in">cd</span> libpng-(version)</span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/libpng</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure>
</li>
<li><p>安装 freetype</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/soft/</span><br><span class="line">tar –zvxf freetype-2.2.1.tar.gz</span><br><span class="line"><span class="built_in">cd</span> freetype-2.2.1  </span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/freetype</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure>
</li>
<li><p>安装 zlib</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /root/Software/</span><br><span class="line">tar –zxvf zlib-1.2.3.tar.gz</span><br><span class="line"><span class="built_in">cd</span> zlib.1.2.3</span><br><span class="line">mkdir /usr/<span class="built_in">local</span>/zlib</span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/zlib</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure>
</li>
<li><p>安装 gettext</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/soft /</span><br><span class="line">tar –zxvf gettext-0.14.5.tar.gz</span><br><span class="line"><span class="built_in">cd</span> gettext-0.14.5</span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/gettext</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure>
</li>
<li><p>安装 libxml</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/soft /</span><br><span class="line">tar –zxvf libxml-1.8.17.tar.gz</span><br><span class="line"><span class="built_in">cd</span> libxml-1.8.17</span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/libxml</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure>
</li>
<li><p>安装 gdbm</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/soft /</span><br><span class="line">tar –zxvf gdbm-1.8.2.tar.gz</span><br><span class="line"><span class="built_in">cd</span> gdbm-1.8.2</span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/gdbm</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure>
</li>
<li><p>安装 libiconv</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/soft /</span><br><span class="line">tar –zxvf libiconv-1.10.tar.gz</span><br><span class="line"><span class="built_in">cd</span> libiconv-1.10</span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/libiconv</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure>
</li>
<li><p>安装 gd2</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/soft /</span><br><span class="line">tar –zxvf gd-2.0.33.tar.gz</span><br><span class="line"><span class="built_in">cd</span> gd-2.0.33</span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/gd2 –with-zlib=/usr/<span class="built_in">local</span>/zlib/ --with-png=/usr/<span class="built_in">local</span>/libpng/ --with-jpeg=/usr/<span class="built_in">local</span>/jpeg/ --with-freetype=/usr/<span class="built_in">local</span>/freetype</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p><strong> 第三步 安装 PHP </strong><br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/soft /</span><br><span class="line">tar –zxvf php-5.0.5.tar.gz</span><br><span class="line"><span class="built_in">cd</span> php-5.0.5.tar.gz</span><br><span class="line">./configure –prefix=/usr/<span class="built_in">local</span>/php –with-apxs2=/usr/<span class="built_in">local</span>/apache/bin/apxs –with-jpeg-dir=/usr/<span class="built_in">local</span>/jpeg/ --with-gettext –<span class="built_in">enable</span>-mbstring –with-libxml-dir=/usr/<span class="built_in">local</span>/libxml –with-png-dir=/usr/<span class="built_in">local</span>/libpng/ --with-gd=/usr/<span class="built_in">local</span>/gd2/ --with-freetype-dir=/usr/<span class="built_in">local</span>/freetype –<span class="built_in">enable</span>-trace-vars –with-zlib-dir=/usr/<span class="built_in">local</span>/zlib/ --with-mysql=/usr/<span class="built_in">local</span>/mysql –with-gdbm-dir=/usr/<span class="built_in">local</span>/gdbm/ --enable-wddx  --with-iconv –<span class="built_in">enable</span>-sockets –<span class="built_in">disable</span>-ipv6</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br><span class="line">cp php.ini-dist /usr/<span class="built_in">local</span>/php/lib/php.ini</span><br></pre></td></tr></table></figure></p>
<p><strong> 第四步 修改 httpd.conf 文件</strong></p>
<p> 编辑 apache 配置文件 httpd.conf<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vi /usr/<span class="built_in">local</span>/apache2/conf/httpd.conf</span><br></pre></td></tr></table></figure></p>
<p>要改的有如下几处:</p>
<p>一般都在 <strong> #AddType application/x-tar .tgz </strong>下加一行<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#LoadModule php5_module modules/libphp5.so</span></span><br><span class="line">AddType application/x-httpd-php .php</span><br></pre></td></tr></table></figure></p>
<p>如果搜索其它地方没有 <strong> LoadModule php5_module modules/libphp5.so </strong> 把上面的 # 号去掉</p>
<p>找到 <strong> DirectoryIndex index.html index.htm</strong>，在后面加 index.php 让它把 index.php 做为默认页</p>
<p>再把 <strong>#ServerName</strong> 的#号去掉,后面的 IP 改成 0.0.0.0  </p>
<p><strong> 第五步 测试</strong><br>在 apache 的根目录下面（/usr/local/apache/htdocs）建立一个文件内容为：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?php</span></span><br><span class="line">    phpinfo();</span><br><span class="line"> <span class="meta">?&gt;</span></span><br></pre></td></tr></table></figure>
<p>保存为 test.php 文件<br>然后重启 apache 服务器，进行如下操作<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#/usr/local/apache/bin/apachectl –k stop</span></span><br><span class="line"><span class="comment">#/usr/local/apache/bin/apachectl –k start</span></span><br></pre></td></tr></table></figure></p>
<p>然后在地址栏里面输入：本机IP/test.php 如果可以看到 php 的版本以及其他相关信息就说明 PHP 已经安装成功了</p>
<h2 id="安装_memcached_&amp;_php-memcache">安装 memcached &amp; php-memcache</h2><p><strong> 第一步  下载相关组件 </strong><br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#wget http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz</span></span><br><span class="line">wget http://pecl.php.net/package/memcache/memcache-1.2.0.tgz</span><br><span class="line">wget http://www.monkey.org/~provos/libevent-1.2.tar.gz</span><br></pre></td></tr></table></figure></p>
<p><strong> 第二步 安装组件</strong></p>
<p>libevent-1.2 安装：<br>默认安装：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># tar –zxvf libevent-1.2.tar.gz</span></span><br><span class="line"> <span class="built_in">cd</span> libevent-1.2</span><br><span class="line"> ./configure</span><br><span class="line"> make</span><br><span class="line"> make install</span><br><span class="line"> make clean</span><br></pre></td></tr></table></figure></p>
<p>建立一个符号连接<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ls <span class="_">-s</span> /usr/<span class="built_in">local</span>/lib/libevent-1.2.so.1 /usr/lib</span><br></pre></td></tr></table></figure></p>
<p>memcached-1.2.2 安装：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">tar –zxvf memcached-1.2.2.tar.gz</span><br><span class="line"><span class="built_in">cd</span> memcached-1.2.2</span><br><span class="line">./configure --prefix=/usr/<span class="built_in">local</span>/memcached</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">make clean</span><br></pre></td></tr></table></figure></p>
<p><strong> 第三步 安装 Memcache 的PHP扩展</strong></p>
<blockquote>
<p>安装Memcache</p>
</blockquote>
<p>1.在<a href="http://pecl.php.net/package/memcache" target="_blank" rel="external">http://pecl.php.net/package/memcache</a> 选择相应想要下载的 memcache 版本。</p>
<p>2.安装 PHP 的 memcache 扩展<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">tar vxzf memcache-2.2.1.tgz</span><br><span class="line"><span class="built_in">cd</span> memcache-2.2.1</span><br><span class="line">/usr/<span class="built_in">local</span>/php/bin/phpize</span><br><span class="line">./configure –<span class="built_in">enable</span>-memcache –with-php-config=/usr/<span class="built_in">local</span>/php/bin/php-config –with-zlib-dir</span><br><span class="line">make</span><br><span class="line">make install</span><br></pre></td></tr></table></figure></p>
<p>3.上述安装完后会有类似这样的提示：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Installing shared extensions: /usr/<span class="built_in">local</span>/php/lib/php/extensions/no-debug-zts-20041030/</span><br></pre></td></tr></table></figure></p>
<p>4.把php.ini中的extension_dir = “./”修改为</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">extension_dir = “/usr/<span class="built_in">local</span>/php/lib/php/extensions/no-debug-zts-20041030/”</span><br></pre></td></tr></table></figure>
<p>5.添加一行来载入 memcache 扩展：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">extension=memcache.so</span><br></pre></td></tr></table></figure></p>
<blockquote>
<p>Memcached 的基本设置：</p>
</blockquote>
<p>1.启动 Memcache 的服务器端：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/usr/<span class="built_in">local</span>/bin/memcached <span class="_">-d</span> -m 10 -u root <span class="_">-l</span> 192.168.1.55 -p 12000 -c 256 -P /tmp/memcached.pid</span><br></pre></td></tr></table></figure>
<p>-d 选项是启动一个守护进程，<br>-m 是分配给 Memcache 使用的内存数量，单位是 MB；<br>-u 是运行 Memcache 的用户；<br>-l 是监听的服务器 IP 地址；<br>-p 是设置 Memcache 监听的端口，最好是 1024 以上的端口；<br>-c 选项是最大运行的并发连接数，默认是 1024；<br>-P 是设置保存 Memcache 的 pid 文件，这里是保存在 /tmp/memcached.pid；</p>
<p>2.如果要结束 Memcache 进程，执行：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">kill</span> <span class="string">'cat /tmp/memcached.pid'</span></span><br></pre></td></tr></table></figure>
<p>也可以启动多个守护进程，不过端口不能重复</p>
<p>3.然后重启 apache 服务器，进行如下操作</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">/usr/<span class="built_in">local</span>/apache/bin/apachectl –k stop</span><br><span class="line">/usr/<span class="built_in">local</span>/apache/bin/apachectl –k start</span><br></pre></td></tr></table></figure>
<p>4.Memcache 环境测试：</p>
<p>建立一个文件为 pptest.php 内容如下：<br><figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?php</span></span><br><span class="line"> $mem = <span class="keyword">new</span> Memcache;</span><br><span class="line"> $mem-&gt;connect(<span class="string">"127.0.0.1"</span>,<span class="number">11211</span>);</span><br><span class="line"> $mem-&gt;set(<span class="string">'key'</span>,<span class="string">'this is a test!'</span>,<span class="number">0</span>,<span class="number">60</span>);</span><br><span class="line"> $val = $mem-&gt;get(<span class="string">'key'</span>);</span><br><span class="line"> <span class="keyword">echo</span> $val;</span><br><span class="line"> <span class="meta">?&gt;</span></span><br></pre></td></tr></table></figure></p>
<p>然后在地址栏里面输入：本机IP/pptest.php 如果可以看到 this is a test! 就说明已经安装成功了</p>

      
    </div>
    
  </div>
  
    
<nav id="article-nav">
  
    <a href="/Aurthur-2015/Use-DD-Install-Centos-USB-In-Mac.html" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption"><</strong>
      <div class="article-nav-title">
        
          Mac 下 dd 命令制作 Centos USB 启动盘
        
      </div>
    </a>
  
  
    <a href="/Aurthur-2015/SSH-Key-Login.html" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">SSH配置私钥登陆服务器</div>
      <strong class="article-nav-caption">></strong>
    </a>
  
</nav>

  
</article>






</div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info">
    	<div class="footer-left">
    		&copy; 2017 Aurthur
    	</div>
      	<div class="footer-right">
      		<a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/litten/hexo-theme-yilia" target="_blank">Yilia</a> by Litten
      	</div>
    </div>
  </div>
</footer>
    </div>
    
  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">


<script>
	var yiliaConfig = {
		fancybox: true,
		mathjax: true,
		animate: true,
		isHome: false,
		isPost: true,
		isArchive: false,
		isTag: false,
		isCategory: false,
		open_in_new: false
	}
</script>
<script src="/js/jquery-1.9.1.min.js"></script>
<script src="/js/main.js"></script>






<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


  </div>
</body>
</html>